import { createRouter, createWebHistory } from 'vue-router';

// 创建路由实例
const router = createRouter({
  // 使用HTML5历史模式（需要服务器配置支持）
  history: createWebHistory(),
  // 路由配置表
  routes: [
    // {
    //   path: '/',
    //   redirect: '/index'  // 添加根路径重定向
    // },
    {
      path: '/',
      component: () => import('@/views/index.vue'), // 修改为箭头函数形式
      meta: { title: '首页' } 
    },
    { 
      path: '/login',
      component: () => import('@/views/Login.vue'),
      meta: { title: '用户登录' } 
    },
    { 
      path: '/newsDetail',
      component: () => import('@/views/news/NewsDetail.vue'),
      meta: { title: '新闻详情' } 
    },
    { 
      path: '/newsList',
      component: () => import('@/views/news/NewsList.vue'),
      meta: { title: '新闻列表' } 
    },
    { 
      path: '/EnterpriseDetail',
      component: () => import('@/views/enterprise/EnterpriseDetail.vue'),
      meta: { title: '企业详情' } 
    },
    { 
      path: '/EnterpriseList',
      component: () => import('@/views/enterprise/EnterpriseList.vue'),
      meta: { title: '企业列表' } 
    },
    { 
      path: '/customerList',
      component: () => import('@/views/customer/customerList.vue'),
      meta: { title: '客户列表' } 
    },
    { 
      path: '/financeList',
      component: () => import('@/views/finance/financeList.vue'),
      meta: { title: '金融列表' } 
    },
    { 
      path: '/financeDetails',
      component: () => import('@/views/finance/financeDetails.vue'),
      meta: { title: '金融详情' } 
    },
    { 
      path: '/supplyList',
      component: () => import('@/views/supply/supplyList.vue'),
      meta: { title: '供需列表' } 
    },
    { 
      path: '/goodsList',
      component: () => import('@/views/goods/goodsList.vue'),
      meta: { title: '商品列表' } 
    },
    { 
      path: '/ProductDetails',
      component: () => import('@/views/goods/ProductDetails.vue'),
      meta: { title: '商品详情' } 
    },
    { 
      path: '/ExhibitionList',
      component: () => import('@/views/exhibition/ExhibitionList.vue'),
      meta: { title: '展会列表' } 
    },
    { 
      path: '/ExhibitionDetail',
      component: () => import('@/views/exhibition/ExhibitionDetail.vue'),
      meta: { title: '展会详情' }
    },
    { 
      path: '/YiNongsInsight',
      component: () => import('@/views/largeScreen/YiNongsInsight.vue'),
      meta: { title: '农业画像' } 
    },
  ],
  scrollBehavior() {
    return { top: 0 }
  }
});

export default router;
